﻿#pragma once
#include "AsGraphicsBasics.h"
#include "AsGraphicsObject.h"

namespace AsGraphicsNamespace {

	AS_MEMBER_CLASS_DECLARATION(AsGraphicsOptionsPanel);

	class AS_GRAPHICS_API AsGraphicsOptionsPanel : public AsGraphicsObject, public AsBinder<AsGraphicsOptionsPanel> {
		Q_OBJECT

	public:
		explicit AsGraphicsOptionsPanel(QObject* parent = nullptr);
		explicit AsGraphicsOptionsPanel(AsGraphics* graphics, QObject* parent = nullptr);
		~AsGraphicsOptionsPanel();

	private:
		AS_MEMBER_CLASS(AsGraphicsOptionsPanel)* mp;

	public:
		void create(AsGraphics* graphics, QObject* parent = nullptr);
		void destroy();

	public:
		int imageCount() const;
		int rowCount() const;
		int columnCount() const;
		QImage getImage(int index);
		QImage getImage(const QString& name);
		QString getImageName(int index);

	public:
		void addImage(QImage image, const QString& name = QString());
		void setImage(int index, QImage image, const QString& name = QString());
		void setImage(const QString& name, QImage image);
		void insertImagePrior(int index, QImage image, const QString& name = QString());
		void insertImageNext(int index, QImage image, const QString& name = QString());
		void insertImagePrior(const QString& name, QImage image, const QString& priorName = QString());
		void insertImageNext(const QString& name, QImage image, const QString& nextName = QString());
		void removeImage(int index);
		void removeImage(const QString& name);
		void clearImage();

	public:
		void setColumnCount(int columnCount);
		void setHorizontalIntervalRatio(double horIntervalRatio);
		void setVerticalIntervalRatio(double verIntervalRatio);
		void setMarginRatio(double marginRatio);
		void setHorveredRectColor(const QPen& pen, const QBrush& fill);
		void setPressedRectColor(const QPen& pen, const QBrush& fill);
		void setStyle_ImageName(const QFont& font, const QColor& color = Qt::black);

	public:
		void setEnable_showNames(bool isEnable = true);
		void setEnable_fixedOptionSizeMode(bool isEnable, int fixedWidth, int fixedHeight = -1);

	signals:
		void sigImageHovered(QImage image, QString name, int index);
		void sigImagePressed(QImage image, QString name, int index);
		void sigImageDoubleClicked(QImage image, QString name, int index);

	};

	typedef AsGraphicsOptionsPanel OptionsPanel;

};
